package com.xyht.sca_s.student_manage_system.modules.enrollmentManagement.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.enrollmentManagement.entity.req.SmsEnrollmentManagementTeacherInfoReq;
import com.xyht.sca_s.student_manage_system.modules.enrollmentManagement.service.SmsEnrollmentManagementTeacherInfoService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 招生管理招生教师 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-01-15
 */
@RestController
@RequestMapping("/enrollment/teacherInfo")
@SecretBody
public class SmsEnrollmentManagementTeacherInfoController {
    @Resource
    private SmsEnrollmentManagementTeacherInfoService smsEnrollmentManagementTeacherInfoService;
    @Resource
    private JwtTokenUtil jwtTokenUtil;

    @PostMapping("/add")
    @ApiModelProperty(value = "添加招生教师")
    public ResponseResult addEnrollmentManagementTeacherInfo(@RequestBody SmsEnrollmentManagementTeacherInfoReq teacherInfoReq) {
        return smsEnrollmentManagementTeacherInfoService.addEnrollmentManagementTeacherInfo(teacherInfoReq);
    }

    @PostMapping("/delete")
    @ApiModelProperty(value = "删除招生教师")
    public ResponseResult deleteEnrollmentManagementTeacherInfo(@RequestBody SmsEnrollmentManagementTeacherInfoReq teacherInfoReq) {
        return smsEnrollmentManagementTeacherInfoService.deleteEnrollmentManagementTeacherInfo(teacherInfoReq);
    }

    @PostMapping("/update")
    @ApiModelProperty(value = "修改招生教师")
    public ResponseResult updateEnrollmentManagementTeacherInfo(@RequestBody SmsEnrollmentManagementTeacherInfoReq teacherInfoReq) {
        return smsEnrollmentManagementTeacherInfoService.updateEnrollmentManagementTeacherInfo(teacherInfoReq);
    }

    @GetMapping("/list")
    @ApiModelProperty(value = "获取招生教师列表")
    public ResponseResult getEnrollmentManagementTeacherInfoList(@RequestParam(value = "searchStr", required = false) String searchStr,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return smsEnrollmentManagementTeacherInfoService.getEnrollmentManagementTeacherInfoList(searchStr, pageNum, pageSize);
    }

    @GetMapping("/detail")
    @ApiModelProperty(value = "获取招生教师详情")
    public ResponseResult getEnrollmentManagementTeacherInfoDetail(@RequestParam(value = "teacherId") String teacherId,
                                                                 @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        return smsEnrollmentManagementTeacherInfoService.getEnrollmentManagementTeacherInfoDetail(teacherId, pageNum, pageSize);
    }
    @GetMapping("/getBindTeacherId")
    @ApiModelProperty(value = "获取绑定教师id")
    public ResponseResult getTeacherIdByUserId(HttpServletRequest request) {
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEnrollmentManagementTeacherInfoService.getTeacherIdByUserId(user_id);
    }
}

